package com.infosys.cabplanning.service.greeting;

import java.util.concurrent.atomic.AtomicLong;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

//import com.infosys.cabplanning.driver.dao.DriverDAO;

@Controller
public class GreetingController {

	@RequestMapping(value = "/cabPlan", produces = "application/json")
	public @ResponseBody void greeting(
			@RequestParam(value = "name", required = false, defaultValue = "World") String name,
			HttpServletRequest httpRequest, HttpServletResponse httpResponse)
			throws Exception {
		System.out.println("Entered Cab Plan method");
		connect(httpRequest, httpResponse);
	}

	/**
	 * 
	 * @return
	 */
	public void connect(HttpServletRequest httpRequest,
			HttpServletResponse httpResponse) {
		String page = null;
		try {
			httpResponse
					.sendRedirect(httpResponse
							.encodeRedirectURL("https://accounts.google.com/o/oauth2/auth?client_id=417499092582-hijkfu2114v7i21243tt6097kqsf38hk.apps.googleusercontent.com&response_type=code&scope=openid%20email&redirect_uri=http://localhost:8088/cabplanning-service/static/driver.html"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}